package com.shxs.controller;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.shxs.model.entity.NovelTable;
import com.shxs.service.INovelTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 小说Controller
 * 
 * @author ruoyi
 * @date 2024-05-31
 */

@RestController
@RequestMapping("/novel")
public class NovelTableController
{
    @Autowired
    private INovelTableService novelTableService;

    /**
     * 查询小说列表
     */
    @GetMapping("/list")
    public JSONArray list(NovelTable novelTable)
    {
        List<NovelTable> list = novelTableService.selectNovelTableList(novelTable);
        return JSONArray.parseArray(JSON.toJSON(list).toString());
    }

    /**
     * 获取小说详细信息
     */
    @GetMapping(value = "/{novelId}")
    public JSONObject getInfo(@PathVariable("novelId") Long novelId)
    {
        return JSON.parseObject(JSON.toJSON(novelTableService.selectNovelTableByNovelId(novelId)).toString());
    }

    /**
     * 删除小说
     */
	@DeleteMapping("/{novelIds}")
    public int remove(@PathVariable Long[] novelIds)
    {
        return novelTableService.deleteNovelTableByNovelIds(novelIds);
    }
}
